-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(casting): @agoric/casting
MVP
#5487
Conversation
b677762
to
8352d4c
Compare
@agoric/streams
library for following on-chain data without transactions@agoric/streams
for read-only following of on-chain data
8352d4c
to
9bdef00
Compare
c065cd7
to
7b1b27e
Compare
@agoric/streams
for read-only following of on-chain data@agoric/chain-streams
MVP
cde3857
to
528e040
Compare
16c6e7a
to
ec85c45
Compare
ec85c45
to
47febae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding naming, I think “mailbox”, “publication”, “rendezvous”, “drop”, or “feed” might be more appropriate. I would like to reserve “stream” to mean bidi async iterator generally, which is what you’re returning from utility methods off your stream.
packages/chain-streams/src/leader.js
Outdated
let lastRespondingEndpointIndex = 0; | ||
|
||
/** @type {import('./types.js').ChainLeader} */ | ||
const leader = Far('round robin leader', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you’re measuring latency and error rate, The Power of Two Random Choices
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want to read a paper right now. Can you be more specific as to what you're recommending, so that I can at least capture it as a TODO?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Round-robin will be fine. Two random produces a slightly better load distribution when some hosts are more or less responsive than others, and does so in constant time, without maintaining a logarithmic heap.
const i1 = Math.floor(Math.random() * options.length)
const i2 = Math.floor(i1 + 1 + Math.random() * (options.length - 1)) % options.length;
if (latencies[i1] < latencies[i2]) {
return options[i1];
} else {
return options[i2];
}
Latencies are initialized to Infinity and updated with the latency of the most recent request/response (before consuming the response body).
Thanks for the feedback. I think I've settled on |
@agoric/chain-streams
MVP@agoric/casting
MVP
5ca9217
to
7749ac4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed the name change.
7749ac4
to
7af7bdb
Compare
7af7bdb
to
07c2be3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last retro-review: golang code looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops... I just found some pending comments. Not critical, I suppose.
@@ -302,6 +303,19 @@ func (k Keeper) GetKeys(ctx sdk.Context, path string) *types.Keys { | |||
return &keys | |||
} | |||
|
|||
func (k Keeper) SetStorageAndNotify(ctx sdk.Context, path, value string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have go test coverage tooling?
/* global globalThis */ | ||
import fetch from 'node-fetch'; | ||
|
||
globalThis.fetch = fetch; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ouch. Why add a powerful global?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm. I suppose this only words in compartments where globalThis
isn't frozen; i.e. where OCap discipline isn't enforced.
export const startFakeServer = (t, fakeValues) => { | ||
const { log = console.log } = t; | ||
const { serialize } = makeMarshal(); | ||
lastPort += 1; | ||
const PORT = lastPort; | ||
return new Promise(resolve => { | ||
log('starting http server on port', PORT); | ||
const app = express(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exporting a startFakeServer
that closes over express
doesn't follow OCap discipline. How about putting app
on t.context
? so the caller would do t.context.app = express()
in test.before()
?
], | ||
]); | ||
|
||
export const develop = async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this develop()
thing used?
* @param {number} ms | ||
* @returns {Promise<void>} | ||
*/ | ||
export const delay = ms => new Promise(resolve => setTimeout(resolve, ms)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No modules should export powerful objects (for example, objects that close over fs).
-- https://github.com/Agoric/agoric-sdk/wiki/OCap-Discipline
End's node-powers.js is a nice approach.
refs: #5385
Description
This is a complete, but polling-based chain casting follower. Being primarily event-driven is a goal for a future PR.
The best description is in https://github.com/Agoric/agoric-sdk/tree/mfig-chain-streams/packages/casting/README.md
As further PRs in this area are merged, the intent is to update this package to take advantage of new features. Notably, the #5466
x/vcast
module will enable full chain support of the abstractions in #5418.Security Considerations
Documentation Considerations
Testing Considerations